@echo off
echo Ubuntu桌面环境 - 网络冲突解决脚本
echo.

REM 检查Docker是否运行
docker info >nul 2>&1
if %errorlevel% neq 0 (
    echo 错误: Docker未运行，请先启动Docker Desktop
    pause
    exit /b 1
)

echo 步骤1: 显示当前网络状态...
echo.
docker network ls --format "table {{.Name}}\t{{.Driver}}\t{{.Scope}}\t{{.IPv4}}"

echo.
echo 步骤2: 停止相关容器...
docker-compose -f docker-compose.lightweight.yml down 2>nul
docker-compose down 2>nul

echo.
echo 步骤3: 清理冲突的网络...
docker network rm ubuntu-desktop_desktop-network 2>nul
docker network rm ubuntu-desktop_desktop-network-lightweight 2>nul
docker network rm ubuntu-desktop_desktop-network-standard 2>nul

echo.
echo 步骤4: 清理未使用的网络...
docker network prune -f

echo.
echo 步骤5: 重新创建网络...
docker network create --driver bridge --subnet 172.25.0.0/16 ubuntu-desktop_desktop-network-lightweight 2>nul
docker network create --driver bridge --subnet 172.26.0.0/16 ubuntu-desktop_desktop-network-standard 2>nul

echo.
echo 步骤6: 验证网络创建...
docker network ls --filter "name=ubuntu-desktop"

echo.
echo ================================
echo 网络冲突解决完成！
echo ================================
echo.
echo 网络配置已更新：
echo   - 轻量级版本: 172.25.0.0/16
echo   - 标准版本: 172.26.0.0/16
echo.
echo 现在可以重新启动服务：
echo   - 轻量级版本: docker-compose -f docker-compose.lightweight.yml up -d
echo   - 标准版本: docker-compose up -d
echo   - 或使用脚本: start.bat 或 start-lightweight.bat
echo.
pause 